<?php
namespace Home\Controller;
use Think\Controller;
header('content-type:text/html;charset=utf-8');
class IndexController extends BaseController {
	
	public function error(){
		$this->display();
	}
	
    public function index(){
    	if(C('is_open')==0){
    		$this->redirect('error');
    	}
    	// $data = DeleteHtml(curlGet("http://www.qm368.com/lotteryV3/draw/hisresult.do?lotCode=BJSC"));
    	
     //    //preg_match('/<td width=\"40%\">开奖号码<\/td><\/tr><tr ><td>(.*?)<\/td><td>(.*?)<\/td><td>(.*?)<\/td><td><span class=\"pk10/',$data,$m_issue);
     //    preg_match('/<tr class=\"bgcolor1\"><td class=\"td1\">(.*?)<\/td><td class=\"td1\">(.*?)<\/td><td class=\"td2\">(.*?)<\/td>/',$data,$m_issue);
     //    $periodnumber = $m_issue[3];//获取期号
     //    $awardtime    = $m_issue[1]." ".$m_issue[2];//开奖时间
     //    //</td><td>--</td></tr><tr class="bgcolor"><td>639909</td><td>2017-09-15</td><td>10:32:00
        // echo $data;

        // exit();
     //    preg_match('/<td class=\"td3\"><span class=\"result\"> <span class=\"pk10 b(.*?)\"><\/span><span class=\"pk10 b(.*?)\"><\/span><span class=\"pk10 b(.*?)\"><\/span><span class=\"pk10 b(.*?)\"><\/span><span class=\"pk10 b(.*?)\"><\/span><span class=\"pk10 b(.*?)\"><\/span><span class=\"pk10 b(.*?)\"><\/span><span class=\"pk10 b(.*?)\"><\/span><span class=\"pk10 b(.*?)\"><\/span><span class=\"pk10 b(.*?)\"><\/span><\/span><\/td>/',$data,$m_number);
     //    $awardnumbers=$m_number[1].",".$m_number[2].",".$m_number[3].",".$m_number[4].",".$m_number[5].",".$m_number[6].",".$m_number[7].",".$m_number[8].",".$m_number[9].",".$m_number[10];//获取开奖号码
     //    F('pk10_No',$periodnumber);
     //    F('pk10_time',$awardtime);
     //    F('pk10_number',$awardnumbers);

     //    echo F('pk10_No')." ".F('pk10_time')." ".F('pk10_number');
     //    exit();
    	$this->display();
    	
        
    	// $res = check_format("2/龙/300");
		   //                  // $pk10data = F('pk10data');
    	// 					$user2 = M('user')->where("id = {$user['id']}")->find();
    	// 					$map['userid'] = $user2['id'];
					// 		$map['number'] = F('pk10data')+1;
					// 		$map['type'] = $res['type'];
					// 		$map['state'] = 1;
					// 		$map['time'] = time();
					// 		$map['jincai'] = "3/龙/300";
					// 		$map['is_add'] = 0;
					// 		$map['add_points'] = 0;
					// 		$map['del_points'] = $res['points'];
					// 		$map['balance'] = $user2['points']-$map['del_points'];
					// 		$map['nickname'] = $user2['nickname'];
					// 		$res2 = M('order')->add($map);

					// 		if($res2){
					// 			/*减分*/
					// 			$res_points = M('user')->where("id = {$user['id']}")->setDec('points',$map['del_points']);
					// 			var_dump( $res_points);
					// 			exit();
					// 		}
							// var_dump($res);
							
					        
		
	}
	public function lottery(){

		//10期结果
		$list = M('number')->order("id DESC")->limit(15)->select();
		$this->assign('list',$list);
		// $this->assign('options',$options);
		$this->display();
	}

	public function user(){
		$user = session('user');
		$userinfo = M('user')->where("id = {$user['id']}")->find();
					if($userinfo){
						$userinfo['error']=0;
					}
					

		$orderlist = M('order')->where("userid = {$user['id']}")->order("id DESC")->limit(5)->select();
		$this->assign('list',$orderlist);
		$this->display();
	}
	
}